import { useState } from "react";
import { makeFacade, RoomFacade } from "@/facade/roomFacade";
import { Assistant, } from "@/models/LiveRoom";
import { useObservable } from '@/utils/rxHelpers';

type RoomHookTuple = [
  RoomFacade,
  string,
  string,
  string,
  Assistant[],
  number,
  string,
  number
];


//需要在页面用到的变量都在这里hook，主要用于简化页面调用逻辑和代码
export function useRoomFacade(): RoomHookTuple {
  const [roomFacade] = useState(() => makeFacade());
  const [roomRole] = useObservable(roomFacade.roomRole$, "");
  const [ownerId] = useObservable(roomFacade.ownerId$, "");
  const [anchorId] = useObservable(roomFacade.anchorId$, "");
  const [assistants] = useObservable(roomFacade.assistants$, []);
  const [likes] = useObservable(roomFacade.likes$, 0);
  const [tips] = useObservable(roomFacade.tips$, "");
  const [muteStatus] = useObservable(roomFacade.muteStatus$, 0);

  return [roomFacade, roomRole, ownerId, anchorId, assistants, likes, tips, muteStatus];
}
